<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 300px;
      height: 40px;
      border: 1px solid #000;

      /* 不允许换行 */
      white-space: nowrap;
      /* 超出隐藏 */
      overflow: hidden;
      /* 设置如果有超出就显示省略号 */
      text-overflow: ellipsis;
    }
  </style>
</head>
<body>
  <div class="box">
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Qui voluptate, alias sapiente sunt officiis culpa. Dolores expedita sequi aliquam quibusdam hic. Omnis delectus nemo eligendi! Quam reprehenderit commodi repudiandae officia.
  </div>
</body>
</html>